﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace DARE
{
    public sealed class CAnimNode : IEquatable<CAnimNode>, IEquatable<int>, IEquatable<string>
    {

        #region Property

        [ContentSerializer]
        public string Name { get; private set; }

        public int Index { get; set; }

        public int ParentIndex { get; set; }

        public CTransform BindPose { get; set; }

        public Matrix InvBindPose { get; set; }

        //[ContentSerializerIgnore]
        public CTransform AbsolutePose { get; set; }

        public bool IsBones { get; set; }

        #endregion

        #region CTOR

        public CAnimNode()
        {
        }

        public CAnimNode(string _name)
        {
            this.Name = _name;
        }

        #endregion

        #region Method


        public static bool operator ==(CAnimNode a, CAnimNode b)
        {
            if ((object)a == (object)b && (object)a == null)
                return true;
            return a.Equals(b);
        }

        public static bool operator !=(CAnimNode a, CAnimNode b)
        {
            if ((object)a == (object)b && (object)a == null)
                return false;
            return !a.Equals(b);
        }

        public static bool operator ==(CAnimNode a, int b)
        {
            if ((object)a == null)
                return true;
            return a.Equals(b);
        }

        public static bool operator !=(CAnimNode a, int b)
        {
            if ((object)a == null)
                return false;
            return !a.Equals(b);
        }

        public bool Equals(CAnimNode other)
        {
            if ((object)other == null)
                return false;
            return (this.Name == other.Name && this.Index == other.Index && this.ParentIndex == other.ParentIndex);
        }

        public bool Equals(int other)
        {
            return this.Index == other;
        }

        public bool Equals(string other)
        {
            return this.Name == other;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        #endregion

    }
}
